package com.xindz.hgq.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.Button;

import com.blankj.utilcode.util.ToastUtils;
import com.xindz.hgq.R;
import com.xindz.hgq.base.options.BaseActivityOptions;
import com.xindz.hgq.base.BasePresenter;
import com.xindz.hgq.base.BaseView;
import com.xindz.hgq.base.BaseActivity;
import com.xindz.hgq.base.MvpInterface;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @name HGQBase
 * @class name：com.xindz.hgq
 * @describe 使用MVP模式开发需要进行一下操作:\n
 * 一,创建View 继承BaseView\n
 * 创建MvpPresenter继承BasePresenter并定义泛型\n
 * 例:MvpPresenter extends BasePresenter<MvpView>\n
 * 二,创建Activity继承BaseActivity并定义泛型 实现MvpInterface 接口\n
 * 例:MvpActivity extends BaseActivity<MvpView, MvpPresenter> implements MvpView, MvpInterface\n
 * 三,setOption方法返回BaseActivityOptions 并开启MVP\n
 * 例:return new BaseActivityOptions().openMVP(this);\n
 * @anthor XINDZ
 * @time 2018/1/11 10:12
 * @change
 * @chang time
 * @class describe
 */
public class MvpActivity extends BaseActivity<MvpView, MvpPresenter> implements MvpView, MvpInterface {

    @BindView(R.id.bt_mvpone_show)
    Button btMvponeShow;

    @Override
    public void showToase(String msg) {
        ToastUtils.showShort(msg);
    }

    @Override
    public BaseActivityOptions setOption() {
        return new BaseActivityOptions().openMVP(this);
    }


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mvpone);
        ButterKnife.bind(this);

    }

    @OnClick(R.id.bt_mvpone_show)
    public void onViewClicked() {
        getPresneter().showToast("QWER");
    }

    @Override
    public BasePresenter createPresneter() {
        return new MvpPresenter();
    }

    @Override
    public BaseView createView() {
        return this;
    }
}
